<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>忘记密码</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post" action="" >
            	<input type="hidden" id="ids" value="{$list['id']}" >
                <div class="layui-form-item">
                    <label for="username" style="font-size:30px" >确认账号</label>
                </div>

			          <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>用户手机号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="phone" name="phone" value="" required="" lay-verify="pass" autocomplete="off" class="layui-input">
                        <input type="button" disabled id="btn" value="获取验证码"  onclick="settime()"/> 
                    </div>
                    <div id="phones" class="layui-form-mid layui-word-aux">
                        
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>验证码
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="yzms" name="yzms" value="" required="" lay-verify="pass" autocomplete="off" class="layui-input">
                    </div>
                    <div id="yzmss" class="layui-form-mid layui-word-aux">
                        
                    </div>
                </div>

                <div class="layui-form-item">
                    <a id="next" href="javascript:;" class="layui-btn">下一步</a>
                </div>
            </form>
        </div>
        <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8"></script>
    
        <script>
            // 验证码倒计时
            var countdown=60; 
            var btn = document.getElementById("btn");
            function settime(){
                if (countdown == 0) { 
                    btn.removeAttribute("disabled");    
                    btn.value="免费获取验证码"; 
                    $.get("__MODULE__/Login/invalid",function(data){

                    })
                    countdown = 60;
                    return;
                } else { 
                    btn.setAttribute("disabled", true); 
                    btn.value="重新发送(" + countdown + ")"; 
                    countdown--; 
                } 
                setTimeout(function() { 
                  settime() ;
                },1000) 
            }
        </script>      
  
        <script>

            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;

              $("#phone").blur(function(){
              	phone = $(this).val();
              	if(phone.match(/^1[3|4|5|8][0-9]\d{4,8}$/)){
              		$.post("__MODULE__/Login/preg_phone",{phone:phone},function(data){
                      if(data==0){
                        $("#phones").css("color",'red').text("手机号码用户中不存在");
                          $("#btn").attr("disabled",true);
                      }else{
                          $("#phones").css('color','green').text("通过");
                        	$("#btn").attr("disabled",false);
                      }
                  });
              	}else{
              		  $("#phones").css("color",'red').text("手机号码格式不正确");
                    $("#btn").attr("disabled",true);
              	}
              });

              $("#yzms").blur(function(){
                yzms = $(this).val();
                if(yzms==""){
                  yzms = Math.random(1000,10000);
                }
                $.post("__MODULE__/Login/contrast",{yzms:yzms},function(data){
                          if(data=="成功"){
                              $("#yzmss").css("color",'green').text("通过");
                              $("#next").attr("href","__MODULE__/Login/addreset");
                          }else{
                              $("#yzmss").css("color",'red').text("验证码错误");
                          }
                });
              });

             
              $("#btn").click(function(){
                 phone = $("#phone").val();
                 $.post('__MODULE__/Login/getyzm',{phone:phone},function(data){

                  });
              })
            }); 
        </script>
    </body>

</html>